package org.baicaixiaozhan.learnsringbootvuedemo.service;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;

/**
 * 基础 crud 服务层逻辑
 *
 * @author baicaixiaozhan
 * @since 2020/11/20
 */
public interface BaseCrudService<T> {

    default Optional<T> getById(Number id) { return Optional.empty(); }

    default Optional<T> getById(CharSequence id) { return Optional.empty(); }

    default List<T> getAllList() { return Collections.emptyList(); }

    default Set<T> getAllSet() { return Collections.emptySet(); }

    default void add(T entity) {}

    default void addBatch(Iterable<T> entity) {}

    default void removeById(Number id) {}

    default void removeById(CharSequence id) {}

    default void modifyById(T entity) {}
}
